## Universidade Federal do Rio Grande do Sul - Instituto de Informatica
## Departamento de Informatica Teorica
## Modelos de Linguagem de Programacao - 2013/1
## Professor: Lucas Schnorr
## Alunos: Felipe Schimidt e Mario Gasparoni Junior
##
##
## 
## Implementacao do modulo 'enemy' seguindo recomendacoes em:
## http://www.pygame.org/docs/
import commons, pygame, score

class Enemy:
	'Enemy class'
	#enemy images/sprites and rects of each sprite
	enemy=0
	enemy_rect=0
	enemy_left_step=0
	enemy_left_step_rect=0
	enemy_right_step=0
	enemy_right_step_rect=0

	#Logical elements
	left_walk = True

	ENEMY_START_X_POS = 1
	ENEMY_START_Y_POS = 205
	ENEMY_X_POS = 0 #current pos of the enemy
	ENEMY_Y_POS = 0
	steps = 0

	def __init__(self):
		self.enemy = pygame.image.load("images/stopped.png")
		self.enemy_rect = self.enemy.get_rect()
		self.enemy_left_step = pygame.image.load("images/walking1_tray.png")
		self.enemy_left_step_rect = self.enemy.get_rect()
		self.enemy_right_step = pygame.image.load("images/walking2_tray.png")
		self.enemy_right_step_rect = self.enemy.get_rect()
		self.ENEMY_X_POS = self.ENEMY_START_X_POS
		self.ENEMY_Y_POS = self.ENEMY_START_Y_POS

 
	def move(self, screen):
		if self.ENEMY_X_POS >= commons.MAX_HEIGHT:
			commons.PLAYER_LIFE -= 5
		if self.ENEMY_X_POS <= commons.MAX_HEIGHT:
			self.ENEMY_X_POS += commons.GAME_LEVEL
			#Draw player life
		else:
			self.ENEMY_X_POS = self.ENEMY_START_X_POS
		if self.left_walk:
			screen.blit(self.enemy_left_step, [self.ENEMY_X_POS, self.ENEMY_Y_POS])
			self.steps += 1
			if self.steps == 15:
				self.left_walk = not self.left_walk
		elif not self.left_walk:
			screen.blit(self.enemy_right_step, [self.ENEMY_X_POS, self.ENEMY_Y_POS])
			self.steps -= 1
			if self.steps == 0:	
				self.left_walk = not self.left_walk
